
<template>
  <hr>
  <div class="flex bg-white justify-between  " >
    <div class="ml-2 pt-1 ">
      <button class="hover:scale-125"  v-if="props.winType != WindowsType.Main"  @click="storeWin.ChangeWindow(WindowsType.Main)">
        <home-two  size="22px"  fill="#FF9800"  :strokeWidth="3" strokeLinecap="square"/>
        <q-tooltip   :delay="800" > 回主界面 </q-tooltip>
      </button>



      <button class="hover:scale-125 ml-2" v-if="props.winType != WindowsType.QuickTools"  @click="storeWin.ChangeWindow(WindowsType.QuickTools)" >
<!--        <i style="font-size: 18px;color: #18c3d4" class="fas fa-th-large"></i>-->
        <application-two theme="filled" size="22" fill="#3F51B5 " strokeLinecap="square"/>

        <q-tooltip   :delay="800" >
          快捷应用界面
        </q-tooltip>
      </button>

      <button class="hover:scale-125 ml-2" v-if="props.winType != WindowsType.Message"  @click="EntryLeastDialog" >
        <message-unread theme="two-tone" size="22px"  fill="#03A9F4 " :strokeWidth="2" strokeLinejoin="bevel" strokeLinecap="square"/>
        <q-tooltip    :delay="800" >
          最新对话Chat界面
        </q-tooltip>
      </button>

      <button class="hover:scale-125  ml-2" @click="ShowPopUser" v-if="props.winType != WindowsType.QuickTools" >
<!--        <i class="fas fa-user" style="font-size: 1.22rem"></i>-->
        <user theme="two-tone" size="22px"  fill="#4da4db" :strokeWidth="2" strokeLinejoin="bevel" strokeLinecap="square"/>
        <q-tooltip    :delay="800" >
          用户中心
        </q-tooltip>

        <PopDialog v-if="storeGlobal.IsLogin" title="用户中心" ref="popUser"  :ClassStr="props.winType == WindowsType.Main ?'w-3/5 bg-white' : 'w-4/5 bg-white'">
          <UserInfo ></UserInfo>
        </PopDialog>

        <PopDialog v-if="!storeGlobal.IsLogin"   title="注册/登录" ref="popLogin"  :ClassStr="props.winType == WindowsType.Main ?'w-96 bg-white' : 'w-80 bg-white'">
          <Login ></Login>
        </PopDialog>
      </button>
<!--      <button  @click="storeWin.ChangeWindow(WindowsType.Main)" class="ml-2">-->
<!--        <i style="font-size: 18px;color: #86b1ca" class="fas fa-mobile-alt"></i>-->
<!--        <q-tooltip   :delay="800" >-->
<!--          窄屏模式-->
<!--        </q-tooltip>-->
<!--      </button>-->
    </div>


    <div  class="mx-2 px-1 " v-if="props.winType!=WindowsType.Main"  >
      <button   @click="PopSetting()" class="hover:scale-125 ml-2 ">
        <q-tooltip   :delay="800" >
          参数设置
        </q-tooltip>
      </button>


      <button class="hover:scale-125 ml-2"  >

        <i class="fas fa-thumbtack " @click="winSetTop"  style="font-size: 18px" :class="isTop? 'text-cyan' : ''" ></i>
        <q-tooltip   :delay="800" >

          {{isTop ? '取消窗体置顶' : '窗体置顶'}}
        </q-tooltip>
      </button>

      <button v-if="props.winType==WindowsType.Message"  @click="PopSetting()" class="hover:scale-125 ml-2 ">
        <i class="fas fa-cog"  style="font-size: 20px;color:#9C27B0 "></i>
        <q-tooltip   :delay="800" >
          参数设置
        </q-tooltip>
        <PopDialog :IsFullWidth="true" ref="popSettingRef" title="设置"   ClassStr="w-full bg-gray-50">
          <Setting></Setting>
        </PopDialog>
      </button>

      <button v-if="props.winType==WindowsType.Message"  @click="PopClipboards()" class=" hover:scale-125 ml-2 ">
        <i class="fas fa-clipboard"   style="font-size: 20px;color: #2196F3 "></i>
        <q-tooltip   :delay="800" >
          剪贴板列表
        </q-tooltip>
        <PopDialog :IsFullWidth="true"  ref="popClipboardRef" title="剪贴板"   ClassStr="w-5/6 bg-gray-50">
          <ClipboardList :ShowContentSize="30"  :PageSize="9"></ClipboardList>
        </PopDialog>
      </button>
<!--      <button  @click="PopSetting()" class="hover:scale-125 ml-2 ">-->
<!--&lt;!&ndash;        <data-display theme="filled" size="22" fill="#0cd1d1" strokeLinecap="square"/>&ndash;&gt;-->
<!--        <i class="fas fa-cloud-upload-alt" style="font-size: 20px;color: #FF5722 "></i>-->
<!--        <q-tooltip   :delay="800" >-->
<!--          数据云端同步-->
<!--        </q-tooltip>-->
<!--      </button>-->

      <button v-if="props.winType !=WindowsType.Main"  @click="SaveCurrSize()" class="hover:scale-125 mt-1 ml-2">
        <!--        <i style="font-size: 20px;color: #1c3265" class="fas fa-save"></i>-->
        <i class="fas fa-desktop"   style="font-size: 20px;color: #1899ad"></i>
<!--        <laptop theme="filled" size="22px" fill="#944eb6" strokeLinecap="square"/>-->
        <q-tooltip   :delay="800" >
          记住当前界面尺寸信息
        </q-tooltip>
      </button>


    </div>


  </div>


  <hr>
</template>
<script setup lang="ts">

import {useWindowsStore, WindowsType} from "../store/windows";
import {defineProps, onMounted, ref} from "vue";
import {ApplicationTwo, HomeTwo, MessageUnread, User} from '@icon-park/vue-next';
import Setting from "../pages/Setting.vue"

import {ToastInfo} from "../utils/Toast";
import {EntryLeastDialog} from "../core/EntryLastDialog";
import PopDialog from "./PopDialog.vue";
import {WindowSetAlwaysOnTop} from "../../wailsjs/runtime";
import {useGlobalStore} from "../store/global";
import Login from "../layout/login.vue";
import UserInfo from "../layout/UserInfo.vue";
import ClipboardList from "./ClipboardList.vue";

let isTop=ref(true)
onMounted(()=>{
  //WindowSetAlwaysOnTop(true)
})

let popUser=ref()
let popLogin=ref()
function ShowPopUser(){
  storeGlobal.value.CheckLogin().then(isLogin=>{})
  if(storeGlobal.value.IsLogin){
    popUser.value.ShowPop()
  }else {
    popLogin.value.ShowPop()
  }
}



function winSetTop(){
  if(!isTop.value){
    WindowSetAlwaysOnTop(true)
    isTop.value=true
    ToastInfo("窗体已置顶")
  }else{
    WindowSetAlwaysOnTop(false)
    isTop.value=false
    ToastInfo("窗体已取消置顶")
  }




}
function winCancelTop(){
  WindowSetAlwaysOnTop(false)
  isTop.value=false
  ToastInfo("已取消置顶")
}

let storeWin=ref(useWindowsStore())
let storeGlobal=ref(useGlobalStore())
let popSettingRef=ref()
let props=defineProps({
    winType:{
        type:Number,
        default:WindowsType.QuickTools
    }
})

function PopSetting(){
  popSettingRef.value.ShowPop()
}

let popClipboardRef=ref()
function PopClipboards(){
  popClipboardRef.value.ShowPop()
}


async function SaveCurrSize() {
  // WindowGetSize().then((size)=>{
  //   if(props.winType == WindowsType.QuickTools){
  //       SetKVT(ConfigKeyWinWidthQuick,String(size.w),SettingTypeSystem)
  //       SetKVT(ConfigKeyWinHeightQuick,String(size.h),SettingTypeSystem)
  //   }
  //   if(props.winType == WindowsType.Message){
  //     SetKVT(ConfigKeyWinWidthMessage,String(size.w),SettingTypeSystem)
  //     SetKVT(ConfigKeyWinHeightMessage,String(size.h),SettingTypeSystem)
  //   }
  //
  //
  // })

  await storeWin.value.SaveCurrWinSize(props.winType)



}
function GetCurrDate():string{
  const currentDate = new Date();

  const options: Intl.DateTimeFormatOptions = {
    year: 'numeric',
    month: '2-digit',
    day: '2-digit',
    hour: '2-digit',
    minute: '2-digit',
    second: '2-digit',
  };

  let formattedDateString = currentDate.toLocaleString('zh-CN', options);
  return formattedDateString
}
</script>

<style scoped>

</style>